#include "ModbusControlStruct.h"

ModbusControlStruct::ModbusControlStruct()
{
    m_deviceAddress = 0;
    m_functionCode = 0;
    m_registerStartAddress = 0;
    m_registerNumber = 0;
}

quint8 ModbusControlStruct::deviceAddress() const
{
    return m_deviceAddress;
}

void ModbusControlStruct::setDeviceAddress(const quint8 &deviceAddress)
{
    m_deviceAddress = deviceAddress;
}

quint8 ModbusControlStruct::functionCode() const
{
    return m_functionCode;
}

void ModbusControlStruct::setFunctionCode(const quint8 &functionCode)
{
    m_functionCode = functionCode;
}

quint16 ModbusControlStruct::registerStartAddress() const
{
    return m_registerStartAddress;
}

void ModbusControlStruct::setRegisterStartAddress(const quint16 &registerStartAddress)
{
    m_registerStartAddress = registerStartAddress;
}

quint16 ModbusControlStruct::registerNumber() const
{
    return m_registerNumber;
}

void ModbusControlStruct::setRegisterNumber(const quint16 &registerNumber)
{
    m_registerNumber = registerNumber;
}

QList<quint16> ModbusControlStruct::registrValueList() const
{
    return m_registrValueList;
}

void ModbusControlStruct::setRegistrValueList(const QList<quint16> &registrValueList)
{
    m_registrValueList = registrValueList;
}

bool ModbusControlStruct::operator ==(const ModbusControlStruct &rhs)
{
    return(m_deviceAddress == rhs.deviceAddress()) &&
          (m_functionCode  == rhs.functionCode())  &&
          (m_registerStartAddress == rhs.registerStartAddress());
}

bool ModbusControlStruct::operator <(const ModbusControlStruct &rhs) const
{
    if (m_deviceAddress < rhs.deviceAddress())
    {
        return true;
    }
    else if (m_deviceAddress == rhs.deviceAddress())
    {
        if(m_functionCode < rhs.functionCode())
        {
            return true;
        }
        else if(m_functionCode == rhs.functionCode())
        {
            return m_registerStartAddress < rhs.registerStartAddress();
        }
    }

    return false;
}

quint16 ModbusControlStruct::pointAddress() const
{
    return m_pointAddress;
}

void ModbusControlStruct::setPointAddress(const quint16 &pointAddress)
{
    m_pointAddress=pointAddress;
}
quint16 ModbusControlStruct::calculationMode()const
{
    return m_calculationMode;
}
void ModbusControlStruct::setCalculationMode(quint16 modeData)
{
    m_calculationMode=modeData;
}

quint16 ModbusControlStruct::queryTime() const
{
    return m_queryTime;
}
void ModbusControlStruct::setqueryTime(quint16 time)
{
    m_queryTime=time;
}

